<template>
  <view>
      <cityPicker :column="column" :default-value="defaultValue" :mask-close-able="maskCloseAble" @confirm="confirm" @cancel="cancel" :visible="visible"/>
      <view @tap="open">{{str || '请设置省市区信息'}}</view>
  </view>
</template>

<script>
  import cityPicker from '@/uni_modules/piaoyi-cityPicker/components/piaoyi-cityPicker/piaoyi-cityPicker'
  export default {
    props: ['currentVal'],
    data() {
        return {
            visible: false,
            maskCloseAble: true,
            defaultValue: '621123',
            // defaultValue: ['河北省','唐山市','丰南区'],
            column: 3
        }
    },
    components: {
        cityPicker
    },
    computed: {
      str: {
        get() {
          return this.currentVal || ''
        },
        set(val) {
          this.$emit('update:currentVal', val.name)
        }
      }
    },
    methods: {
        open () {
            this.visible = true
        },
        confirm (val) {
            console.log(val)
            this.str = val
            this.visible = false
        },
        cancel () {
            this.visible = false
        }
    },
    onShareAppMessage(res) {
        if (res.from === 'button') { // 来自页面内分享按钮
            console.log(res.target)
        }
        return {
            title: 'data-cityPicker省市区地址选择器！',
            path: '/pages/cityPicker/cityPicker'
        }
    },
    onShareTimeline(res) {
        if (res.from === 'button') { // 来自页面内分享按钮
            console.log(res.target)
        }
        return {
            title: 'data-cityPicker省市区地址选择器！'
        }
    }
  }
</script>

<style lang="scss">

</style>